/******************************************************************************

Welcome to GDB Online.
  GDB online is an online compiler and debugger tool for C, C++, Python, PHP, Ruby, 
  C#, OCaml, VB, Perl, Swift, Prolog, Javascript, Pascal, COBOL, HTML, CSS, JS
  Code, Compile, Run and Debug online from anywhere in world.

*******************************************************************************/
#include <iostream>
#include <string>

int main() {
    std::cout << "Введите скобочную последовательность" << std::endl;
    std::string s;
    std::cin >> s;
    std::string s1 = "";

    for (char c : s) {
        if (c == '(' || c == '[' || c == '<' || c == '{') {
            s1 += c;
        }
        if (c == ')' || c == ']' || c == '>' || c == '}') {
             if (s1.length() > 0) {
                 (s1[s1.length() - 1] == ')' || s1[s1.length() - 1] == ']' || s1[s1.length() - 1] == '>' || s1[s1.length() - 1] == '}'); {
                    s1 = s1.substr(0, s1.length() - 1);
                 }
            }
        }
        std::cout << s1 << std::endl;
    }

    std::cout << s1 << std::endl;

    if (s1.length() == 0) {
        std::cout << "True" << std::endl;
    }
    else {
        std::cout << "False" << std::endl;
    }

    return 0;
}






